package value

import (
	"context"
	"tongquetai_server/activity_vk/infrastructure/utils"
)

type TqtRankCoreAward struct {
	No    int       `json:"no" header:"编号" validate:"gt=0"`
	Award []TqtItem `json:"award" header:"道具内容" validate:"gt=0"`
}

type SvrRankCoreAward = string

// ------------------------------------ 适配器部分 -----------------------------------

func ToSvrRankCoreAward(tqtRankCoreAward []TqtRankCoreAward) []SvrRankCoreAward {
	res := make([]SvrRankCoreAward, 0, len(tqtRankCoreAward))
	for _, v := range tqtRankCoreAward {
		res = append(res, v.Award[0].ItemId)
	}
	return res
}

func ToTqtRankCoreAward(ctx context.Context, svrRankCoreAward []SvrRankCoreAward) []TqtRankCoreAward {
	res := make([]TqtRankCoreAward, 0, len(svrRankCoreAward))
	for i, v := range svrRankCoreAward {
		res = append(res, TqtRankCoreAward{
			No: i + 1,
			Award: []TqtItem{
				{
					ItemId:   v,
					ItemName: utils.GetItemNameByItemId(ctx, v),
				},
			},
		})
	}
	return res
}
